﻿using movie.tool.module.film.model;
using movie.tool.module.http;
using System.Net.Http;
using System.Net.Http.Json;
using System.Windows;
using System.Windows.Controls;

namespace movie.tool.module.film.ui
{
    /// <summary>
    /// MovieBaseInfoEditorControl.xaml 的交互逻辑
    /// </summary>
    public partial class MovieBaseInfoEditorControl : UserControl
    {
        public static readonly DependencyProperty ConfigProperty = DependencyProperty.Register("Config", typeof(MovieProject), typeof(MovieBaseInfoEditorControl));
        public MovieProject Config
        {
            get => (MovieProject)GetValue(ConfigProperty);
            set => SetValue(ConfigProperty, value);
        }
        public MovieBaseInfoEditorControl()
        {
            InitializeComponent();
        }

        private void MovieInfoControl_MovieTagsChanged(string[] obj)
        {
            if (Config != null && Config.Movie != null)
            {
                Config.Movie.Tag = obj;
            }
        }
        private void MovieInfoControl_NotifyMovieTagProperty()
        {
            if (Config != null && Config.Movie != null)
            {
                Config.Movie.NotifyTagsChanged();
            }
        }

        private async void MovieBaseInfoSubmitClick(object sender, RoutedEventArgs e)
        {
            bool result = await MovieClient.UpdateMovieInfo(Config.Movie, Config.Id);
            if (result)
            {
                //提交成功
                MessageBox.Show("提交成功");
            }
        }
    }
}
